﻿using System;
using System.Collections.Generic;
using System.Text;
using GD.ModelContest.Model;
using System.Collections;

namespace GD.ModelContest.DataAccess.Impl.IBatisNet
{
    public class MessageSqlMapDao : BaseSqlMapDao, IMessageDao
    {
        #region mc_message 对象

        public bool InsertMessage(mc_message msg)
        {
            object obj = ExecuteInsert("Insertmc_message", msg);

            if ((int)obj > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool UpdateMessage(mc_message msg)
        {
            int ret = ExecuteUpdate("Updatemc_message", msg);

            if (ret > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public bool DelteMessage(int msgId)
        {
            object obj = ExecuteDelete("Deletemc_message", msgId);

            if ((int)obj > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public IList<mc_message> GetMessageCollection(int userId, int pageIndex, int pageSize, ref int count)
        {
            Hashtable ht = new Hashtable();
            ht["UserId"] = userId;

            count = ExecuteQueryForObject<int>("SelectMessageCollectionByUserIdCount", ht);
            return ExecuteQueryForList<mc_message>("SelectMessageCollectionByUserId", ht, (pageIndex - 1) * pageSize, pageSize);
        }

        #endregion
    }
}
